#!/usr/bin/env python3

import sys
import os

# 添加当前目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

try:
    print("正在导入模块...")
    from fastapi import FastAPI
    print("✓ FastAPI导入成功")
    
    from app.database.database import engine
    print("✓ 数据库引擎导入成功")
    
    from app.models import models
    print("✓ 模型导入成功")
    
    print("正在创建数据库表...")
    models.Base.metadata.create_all(bind=engine)
    print("✓ 数据库表创建成功")
    
    from main import app
    print("✓ 应用导入成功")
    
    print("正在启动服务器...")
    import uvicorn
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
    
except Exception as e:
    print(f"❌ 错误: {e}")
    import traceback
    traceback.print_exc()
